<template>
  <el-form :model="form" label-width="120px" :show-message="false" ref="form" :rules="rules" :inline="true">
    <el-form-item label="回访结果:" prop="resultDictId">
      <el-select clearable v-model="form.resultDictId" placeholder="请选择回访结果">
        <el-option
          v-for="item in dict['回访结果']"
          :key="item.index"
          :value="item.value"
          :label="item.text"
        />
      </el-select>
    </el-form-item>
    <el-form-item label="回访时间:" prop="anewVisitTime">
      <el-date-picker
        v-model="form.anewVisitTime"
        style="width: 209px"
        type="datetime"
        :disabled="true"
        placeholder="回访时间:"
      ></el-date-picker>
    </el-form-item>
    <el-form-item label="回访备注:" prop="remark">
      <el-input type="textarea" v-model="form.remark" clearable maxlength="1000" style="width: 544px" show-word-limit :autosize="{ minRows: 4, maxRows: 6 }" placeholder="备注"></el-input>
    </el-form-item>
    <el-row>
      <el-col :span="24" align="center">
        <el-form-item>
          <el-button type="primary" style="border: 0;width: 100px" @click="onSubmit">保存</el-button>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>
  import { getDict } from '@/utils'
  import { parseTimeToYMDHMS } from '@/utils'
  export default {
    name: 'DialogDataForm',
    props: {
      value: {
        type: Object,
        default: () => ({
        })
      }
    },
    data() {
      return {
        dict: {},
        form: {
          id: this.value.id,
          resultDictId: '',
          anewVisitTime: parseTimeToYMDHMS(new Date()),
          remark: ''
        },
        rules: {
          resultDictId: [{required: true, trigger: 'change'}],
          anewVisitTime: [{required: true, trigger: 'change'}],
          remark: [{required: true, trigger: 'blur'}]

        }
      }
    },
    async created() {
      this.dict = getDict(['回访结果'])
    },
    methods: {
      onSubmit() {
        this.$refs.form.validate(valid => {
          if (valid) {
            const options = this.form
            this.$emit('operate', options)
          } else {
            return false
          }
        })
      }
    }
  }
</script>
<style lang="scss" scoped>
</style>

